package org.aplombh.java.awcing.basic.basics.prefixSumAndDifferencen;

import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * compute the sum of the submatrices
 */
public class SumOfSubmatrices_794 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();

        int[][] a = new int[n + 1][m + 1];
        int[][] s = new int[n + 1][m + 1];

        IntStream.rangeClosed(1, n).forEach(i -> {
            IntStream.rangeClosed(1, m).forEach(j -> {

                a[i][j] = scanner.nextInt();
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
            });
        });

        while (q-- != 0) {
            int x1 = scanner.nextInt();
            int y1 = scanner.nextInt();
            int x2 = scanner.nextInt();
            int y2 = scanner.nextInt();

            System.out.println(s[x2][y2] - s[x1 -1][y2] -s[x2][y1 - 1] + s[x1 - 1][y1 - 1]);
        }
    }
}
